{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-page">
	<h3 class="pb-2">对学员【{$admin['name']}】的评价</h3>
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray">评 价 分<font>*</font></td>
			<td><div id="score" lay-options="{value: {$appraise.appraise_user_score|default=6}}"></div></td>
		</tr>
		<tr>
			<td class="layui-td-gray">评价内容<font>*</font></td>
			<td colspan="5"><textarea name="appraise_user" placeholder="请输入评价内容" lay-verify="required" lay-reqText="请输入评价内容" class="layui-textarea" style="height:360px;">{$appraise.appraise_user|default=''}</textarea></td>
		</tr>
	</table>
	<div class="pt-4">
		<input type="hidden" name="appraise_user_score" value="{$appraise.appraise_user_score|default=6}"/>
		<input type="hidden" name="train_id" value="{$detail.id}"/>
		<input type="hidden" name="uid" value="{$admin.id}"/>
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	var moduleInit = ['tool'];

	function gouguInit() {
		var form = layui.form, tool = layui.tool,rate = layui.rate;;
		 // 渲染
		  rate.render({
			elem: '#score',
			length: 10,
			text: true,
			choose: function(value){
				$('[name="appraise_user_score"]').val(value);
			}
		  });
		
		//监听提交
		form.on('submit(webform)', function (data) {
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			let clickbtn = $(this);
			if(data.field.appraise_user_score==0){
				layer.msg('评价分不能为0');
				return false;
			}
			tool.post("/train/api/appraise_add", data.field, callback,clickbtn);
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->